
let students = [
    {id: 1001 , name: '老秦' , age: 19 },
    {id: 1002 , name: '小丽' , age: 18 },
    {id: 1003 , name: '小张' , age: 20 } ,
    {id: 1004 , name: '阿芳' , age: 16 },
    {id: 1005 , name: '洁洁' , age: 19 },
    {id: 1001 , name: '虹虹' , age: 19 }
]

students.forEach( e => console.log(e.id,e.name,e.age) ); 

console.log( '- - - '.repeat(10) );

// Array.prototype.filter( fn ) 根据 fn 过滤数组并返回满足条件的元素组成新数组
let result = students.filter( e => e.age < 20 );
console.log( result );

console.log( '- - - '.repeat(10) );

// Array.prototype.some( fn )
console.log( students.some( e => e.age === 20 ) ); // true
// Array.prototype.every( fn )
console.log( students.every( e => e.age === 20 ) ); // false

console.log( '- - - '.repeat(10) );

const array1 = [1, 4, 9, 16 ];

// Array.prototype.map( fn )
let array2 = array1.map( e => e ** 0.5 );
console.log( array2 );
console.log( array1 );

let array3 = students.map( e => { e.age = 22 ; return e ; } );
array3.forEach( e => console.log( e ) );